package com.itheima.controller.cos;

import com.itheima.core.R;
import com.itheima.utils.CosClientUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/minio")
public class MinioController {
    /**
     * 文件上传
     * @param file
     * @return
     */
    @PostMapping("/upload")
    public R upload(@RequestParam(value = "file") MultipartFile file){
        if (file == null){
            return R.error("上传的文件为空！");
        }
        //String uploadfile= minioService.upload(file);
        String uploadfile = CosClientUtils.uploadfile(file);
        return R.success("success",uploadfile);
    }
}
